package com.thread.singleton;

/**
 * 静态内部类实现无锁单例
 * 线程安全
 * @link com.thread.singleton.SingletonDemo
 */
public class StaticInnerClassSingletonDemo {

    private StaticInnerClassSingletonDemo() {
    }

    private static class StaticInnerClassSingletonDemoUtil{
        private static StaticInnerClassSingletonDemo staticInnerClassSingletonDemo = new StaticInnerClassSingletonDemo();
    }

    /**
     * 第一次调用的时候加载内部类的时候初始化
     * @return
     */
    public StaticInnerClassSingletonDemo getInstance(){
        return StaticInnerClassSingletonDemoUtil.staticInnerClassSingletonDemo;
    }
}
